<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>小说类别管理</title>
	<link rel="stylesheet" type="text/css" href="/secondhand/css/query.css" />
	<script type="text/javascript" src="/secondhand/js/jquery-3.2.1.js"></script>
	<script type="text/javascript">
		$(function () {
			var param = new URLSearchParams(window.location.search);
			var pageNo = param.get("pageNo");
			var likeValue = param.get("likeValue");
			selectByPage(pageNo,likeValue);
			//点击查询按钮
			$("#selectByLikeValue").click(function (){
				var likevaluestr=$.trim($("#likevaluestr").val());
				selectByPage(1,likevaluestr);
			})
		})
		function selectByPage(pageNo,likevalue){
			var url = "/secondhand/selectByPage.goods";
			var paramObj = {
				"pageNo":pageNo,
				"likeValue":likevalue
			};
			$.post(url,paramObj,function (data) {
				// if(data==""){
				// 	window.parent.href="/secondhand/login.html";
				// }
				$("#tbodyList").empty();
				var jsonObj = JSON.parse(data);
				var recordList = jsonObj.recordList;
				for (var i = 0; i < recordList.length; i++) {
					$("<tr><td>"+recordList[i].goodsid+"</td><td>"
							+recordList[i].userid+"</td><td>"
							+recordList[i].goodsname+"</td><td>"
							+recordList[i].goodsprice+"</td><td>"
							+recordList[i].createtime+"</td><td>"
							+recordList[i].description+
					"</td><td><a href='/secondhand/saveOne.shopping?goodsid=" +recordList[i].goodsid+ "&userid="+recordList[i].userid+ "'>加入购物车</a></td></tr>").appendTo($("#tbodyList"));
				}
				$("#likevaluestr").val(jsonObj.likeValue);//回填查询条件
				$("#recordCount").text(jsonObj.recordCount);//总记录数
				$("#totalPages").text(jsonObj.totalPages);//总页数
				$("#pageNo").text(jsonObj.pageNo);//当前页
				//首页
				$("#firstPage").prop("href","/secondhand/toList.goods?pageNo=1&likeValue="+jsonObj.likeValue);
				//上一页
				if(jsonObj.pageNo!=1)
				$("#prevPage").prop("href","/secondhand/toList.goods?pageNo="+(jsonObj.pageNo-1)+"&likeValue="+jsonObj.likeValue);
				//下一页
				if(jsonObj.pageNo!=jsonObj.totalPages)
				$("#nextPage").prop("href","/secondhand/toList.goods?pageNo="+(jsonObj.pageNo+1)+"&likeValue="+jsonObj.likeValue);
				//尾页
				$("#tailPage").prop("href","/secondhand/toList.goods?pageNo="+jsonObj.totalPages+"&likeValue="+jsonObj.likeValue);
			})
		}
		function  confirmDelete(aNode){
			var goodsName=$(aNode).parent().parent().find("td").eq(1).text();
			if(!confirm("确定删除"+goodsName+"的信息吗")){
				event.preventDefault();//阻止控件的默认行为
			}
		}
	</script>
</head>
<body>
<div id="top">·当前位置： 商品管理 -- 查看商品信息</div>
<div id="contexttop">
	<table id="tab" border="1">
		<tr>
			<td colspan="6" height="50px">
				<input type="text" id="likevaluestr" title="商品ID、商品名称、描述" placeholder="商品ID、商品名称、描述" />
				<input type="button" value="查询" id="selectByLikeValue"/>
			</td>
		</tr>
		<tr bgcolor=" #a2decd">
			<th>商品ID</th>
			<th>卖家ID</th>
			<th>商品名称</th>
			<th>商品价格</th>
			<th>创建时间</th>
			<th>描述</th>
			<th >操作</th>
		</tr>
		<tbody id="tbodyList">
		</tbody>
	</table>
</div>
<div align="center" id="contextbotton">
	&nbsp;总记录数<span id="recordCount"></span>条&nbsp;共<span id="totalPages"></span>页 &nbsp;
	<a id="firstPage" href="#">首页</a>&nbsp;
	<a id="prevPage" href="#">上一页</a> &nbsp;
	<a id="nextPage" href="#">下一页</a> &nbsp;
	<a id="tailPage" href="#">尾页</a>
	&nbsp;第<span id="pageNo"></span>页
</div>
</body>
</html>